package com.centit.jddtgzsz.dao;

import java.util.HashMap;
import java.util.Map;

import com.alibaba.fastjson.JSONArray;
import com.centit.framework.core.dao.CodeBook;
import com.centit.framework.jdbc.dao.BaseDaoImpl;
import com.centit.framework.jdbc.dao.DatabaseOptUtils;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.centit.jddtgzsz.po.JddtGzsz;
import com.centit.support.database.utils.PageDesc;
import com.centit.support.database.utils.QueryAndNamedParams;
import com.centit.support.database.utils.QueryUtils;

import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;



/**
 * JddtGzszDao  Repository.
 * create by scaffold 2020-03-10 
 * @author codefan@sina.com
 * T_JDDT_GZSZ【机队动态监控规则设置表】机队动态监控规则设置表   
*/

@Repository
public class JddtGzszDao extends BaseDaoImpl<JddtGzsz,java.lang.String>
	{

	public static final Log log = LogFactory.getLog(JddtGzszDao.class);
	
	@Override
	public Map<String, String> getFilterField() {
		if( filterField == null){
			filterField = new HashMap<String, String>();

			filterField.put("recId" , CodeBook.EQUAL_HQL_ID);


			filterField.put("jksxglId" , CodeBook.EQUAL_HQL_ID);

			filterField.put("status" , CodeBook.EQUAL_HQL_ID);

			filterField.put("txtype" , CodeBook.EQUAL_HQL_ID);

			filterField.put("txday" , CodeBook.EQUAL_HQL_ID);

			filterField.put("dataValid" , CodeBook.EQUAL_HQL_ID);

			filterField.put("insUsercode" , CodeBook.EQUAL_HQL_ID);

			filterField.put("insTime" , CodeBook.EQUAL_HQL_ID);

			filterField.put("editUsercode" , CodeBook.EQUAL_HQL_ID);

			filterField.put("editTime" , CodeBook.EQUAL_HQL_ID);

			filterField.put("delUsercode" , CodeBook.EQUAL_HQL_ID);

			filterField.put("delTime" , CodeBook.EQUAL_HQL_ID);

		}
		return filterField;
	} 
	
	public JSONArray getJSONArrayList(Map<String, Object> filterMap, PageDesc pageDesc) {
		String sql = "SELECT gz.*,JK.SXNAME,JK.REC_ID AS sxcode FROM T_JDDT_GZSZ gz LEFT JOIN T_JDDT_JKSXGL jk ON jk.REC_ID = GZ.JKSXGL_ID WHERE gz.DATA_VALID = 'T' " + 
				"[ :(like)sxname | and jk.SXNAME like :sxname ]" +
				"[ :jksxglId | and gz.JKSXGL_ID = :jksxglId ]" +
				"[ :txtype| and gz.TXTYPE  = :txtype ]" +
				"[ :recId| and gz.REC_ID  = :recId ]" +
				"[ :status| and gz.STATUS  = :status ]";
		QueryAndNamedParams params = QueryUtils.translateQuery(sql, filterMap);
		JSONArray jsonArray = DatabaseOptUtils.listObjectsByNamedSqlAsJson(this, params.getQuery(), params.getParams(), pageDesc);
		if (jsonArray == null) {
			return new JSONArray();
		}
		return jsonArray;
	}
}
